var mongoConn = require('../utils/store').mongoConn;

module.exports = {
  readDict: function (callback) {
    mongoConn.find('words', {}, function (err, result) {
      if(err) callback(err, null);
      else {
        for (var i = 0; i < result.length; i++) {
          delete result[i]._id;
        }
        callback(null,result);
      }
    })
  },

  saveWord: function (word, object, callback) {
    mongoConn.update('words', {word: word}, object, function (err) {
      if(err) callback(err);
      else callback(null);
    });
  }
};